class TakeComment extends React.Component {
    // 3.1 创建ref，准备获取输入框的value
    content = React.createRef()
    // 3.2 添加微博的函数
    async addWeibo() {
        // 3.2.1 通过ref获取input的value
        const content = this.content.current.value.trim()
        if (content.length === 0) {
            alert('内容不能为空')
            return
        }
        // 3.2.2 发请求写入数据
        const result = await request.post('/weibo', { content })
        alert(result.msg)
        // 3.2.3 清空输入框
        this.content.current.value = null
        this.props.getWeibo()
    }
    render() {
        return (
            <div className="takeComment">
                <textarea ref={this.content} name="textarea" className="takeTextField" id="tijiaoText"></textarea>
                <div className="takeSbmComment">
                    <input onClick={this.addWeibo.bind(this)} type="button" className="inputs" value="" />
                </div>
            </div>
        )
    }
}